<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>添加微信公众号 - [[${configs.title}]]</title>
    <link rel="stylesheet" href="/statics/layui-v2.8.15/css/layui.css">
    <link rel="stylesheet" href="/statics/css/admin/common.css">
</head>

<body>
    <!-- 内容主体区域 -->
    <div class="main-body">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>添加公众号</legend>
        </fieldset>
        <form class="layui-form my-form">
            <div class="layui-form-item">
                <label class="layui-form-label">部门名称</label>
                <div class="layui-input-block my-input">
                    <input type="text" name="department" lay-verify="required" autocomplete="off" placeholder="请输入部门名称" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">公众号名称</label>
                <div class="layui-input-block my-input">
                    <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入公众号名称" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">公众号ID</label>
                <div class="layui-input-block my-input">
                    <input type="text" name="mpId" lay-verify="required" autocomplete="off" placeholder="请输公众号原始ID" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">公众号AppId</label>
                <div class="layui-input-block my-input">
                    <input type="text" name="appId" lay-verify="required" autocomplete="off" placeholder="请输公众号AppId" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">关注公众号自动回复内容</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入关注公众号自动回复内容" name="flowReplyMessage" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">给公众号发消息自动回复内容</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入给公众号发消息自动回复内容" name="sendReplyMessage" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="addCategory">保 存</button>
                </div>
            </div>
        </form>
    </div>
    <script src="/statics/layui-v2.8.15/layui.js"></script>
    <script>
        // JavaScript代码区域
        layui.use(['form', 'upload', 'element', 'laydate'], function () {
            let $ = layui.jquery, form = layui.form;

            // 监听提交
            form.on('submit(addCategory)', function (data) {
                data = data.field;
                $.ajax({
                    type: 'post',
                    url: '/admin/wechat/save',
                    dataType: 'json',
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(data),
                    success: function (result) {
                        if (result.code === 0) {
                            layer.msg('添加成功。');
                            setTimeout(function () {
                                location.href="/admin/wechat";
                            }, 1000);
                        } else {
                            layer.msg(result.msg);
                        }
                    }
                });
                return false;
            });
        });
    </script>
</body>

</html>